# _*_ coding:utf-8 _*_

from menus.functiontree import functions



# 获取功能菜单
def get_function_menu():
    menus = list()
    for fun in functions:
        item = dict()
        item['title'] = fun['title']
        if 'icon' in fun:
            item['icon'] = fun['icon']
        if 'target' in fun:
            item['target'] = fun['target']	
        if 'child' in fun:
            item['child'] = get_function_menu_child(fun)
        menus.append(item)
    return menus


# 获取功能菜单-子
def get_function_menu_child(fun):
    children = list()
    if 'child' not in fun:
        return children
    for m in fun['child']:
        item = dict()
        item['title'] = m['title']
        if 'icon' in m:
            item['icon'] = m['icon']
        if 'href' in m:
            item['href'] = m['href']
        if 'target' in m:
            item['target'] = m['target']
        if 'child' in m:
            item['child'] = get_function_menu_child(m)
        children.append(item)
    return children